clc;clear all;close all;
HiddenUnitNum=10;

dataset = load('dataset.mat');  
BP1 = struct2cell(dataset);
dataset1 = cell2mat(BP1);

Theta = load('Theta.mat');
BP2 = struct2cell(Theta);
Theta1 = cell2mat(BP2);
IN=double(dataset1(1:6,1:2:7000));
OUT=double(Theta1(1:6,1:2:7000));
p=IN;  
t=OUT;   
[pn,input_str] = mapminmax(p) ;
[tn,output_str] = mapminmax(t) ;
TrainSamIn=pn;
TrainSamOut=tn;
net=newff(minmax(pn),[HiddenUnitNum 6],{'logsig','purelin'},'trainlm');
net.trainParam.show=10;
net.trainParam.lr=0.05; 
net.trainParam.epochs=50000;
net.trainParam.goal=10^(-4);  
net.divideFcn = '';
net=train(net,pn,tn);


INtest=dataset1(1:6,2:2:1000);
OUTtest=Theta1(1:6,2:2:1000);

ptest=INtest;
ttest=OUTtest;
[pntest,input_str] = mapminmax(ptest) ;
[tntest,output_str] = mapminmax(ttest) ;
antest=sim(net,pntest);
a = mapminmax('reverse',antest,output_str);
[xxx,Ntest]=size(OUTtest);
Etheta1=sum((a(1,:)-ttest(1,:)).^2,2);                                     
Etheta2=sum((a(2,:)-ttest(2,:)).^2,2); 
Etheta3=sum((a(3,:)-ttest(3,:)).^2,2);
Etheta4=sum((a(4,:)-ttest(4,:)).^2,2);
Etheta5=sum((a(5,:)-ttest(5,:)).^2,2);
Etheta6=sum((a(6,:)-ttest(6,:)).^2,2);
(Etheta1/700)^0.5;
(Etheta2/700)^0.5;
(Etheta3/700)^0.5;
(Etheta4/700)^0.5;
(Etheta5/700)^0.5;
(Etheta6/700)^0.5;
